package com.ivi.car.module.maintain.view.fragment;

import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.ivi.car.R;
import com.ivi.car.bean.MaintainCarPlanBean;
import com.ivi.car.module.maintain.view.adapter.MaintainCarPlanAdapter;

import java.util.ArrayList;
import java.util.List;


/**
 * Created by zhaolong.han on 2018/3/7. 养车计划
 */

public class PlanFragment extends Fragment {
  protected Context mContent;

  private RecyclerView mRecyclerView;
  private List<MaintainCarPlanBean> listData = new ArrayList<>();

  public static PlanFragment newInstance() {
    Bundle args = new Bundle();
    PlanFragment fragment = new PlanFragment();
    fragment.setArguments(args);
    return fragment;
  }

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mContent = getContext();
  }

  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
      Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_maintain_plan, null);
    mRecyclerView = view.findViewById(R.id.mRecyclerView);
    initData();
    initView();
    return view;
  }

  private void initView() {
    mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    MaintainCarPlanAdapter mAdapter = new MaintainCarPlanAdapter(listData);
//    mAdapter.setNewData(listData);
    mRecyclerView.setAdapter(mAdapter);
  }

  private void initData() {
    MaintainCarPlanBean bean1 = new MaintainCarPlanBean(MaintainCarPlanBean.ITEM2);
    listData.add(bean1);
    MaintainCarPlanBean bean2 = new MaintainCarPlanBean(MaintainCarPlanBean.ITEM2);
    listData.add(bean2);
    MaintainCarPlanBean bean3 = new MaintainCarPlanBean(MaintainCarPlanBean.ITEM1);
    listData.add(bean3);
    MaintainCarPlanBean bean4 = new MaintainCarPlanBean(MaintainCarPlanBean.ITEM2);
    listData.add(bean4);
    MaintainCarPlanBean bean5 = new MaintainCarPlanBean(MaintainCarPlanBean.ITEM2);
    listData.add(bean5);
  }

}
